'use strict';

// import myaxios from ("axios")
const myaxios = require("axios")
const Controller = require('egg').Controller;

class HomeController extends Controller {
	async index() {
		const {
			ctx
		} = this;
		ctx.body = 'hi, egg';
	}
	async s() {
		// console.log(this.ctx.request);
		this.ctx.body = 666;
	}
	async sina() {
		let k = await myaxios.get(
			"https://api.weibo.com/2/statuses/home_timeline.json?access_token=2.003EPXtHmzgRxCd987f3722d0byFch")

		//  console.log(k.data.statuses);
		this.ctx.body = k.data.statuses
	}
	async picture() {
		const {
			ctx
		} = this;
		let get = ctx.request.query
		console.log(get.imgId)
		let re = `select *from goods where goods_id=${get.imgId}`
		let mas = await this.app.mysql.query(re)
		console.log(mas)
		ctx.body = {
			answer:mas
		}
	}
	async test() {
		const {
			ctx
		} = this;
		let res = `select *from goods where goods_sort="面包"`
		let res1 = `select *from goods where goods_sort="蛋糕"`
		let res2 = `select *from goods where goods_sort="小食"`
		let res6 = `select *from goods where goods_sort="配件"`
		let res3 = `select *from goods`
		let res4 = `select *from details_img`
		let res5 = `select *from details_page`
		let res7 = `select *from user_account`
		let res8 = `select *from goods_comment`
		let res9 = `select *from user`
		let ansor = await this.app.mysql.query(res)
		let ansor1 = await this.app.mysql.query(res1)
		let ansor2 = await this.app.mysql.query(res2)
		let ansor3 = await this.app.mysql.query(res3)
		let goodsData1 = await this.app.mysql.query(res4)
		let goodsData2 = await this.app.mysql.query(res5)
		let partsData1 = await this.app.mysql.query(res6)
		let accountLevel = await this.app.mysql.query(res7)
		let accountcontent = await this.app.mysql.query(res8)
		let userinfor = await this.app.mysql.query(res9)


		ctx.body = {
			ansor,
			ansor1,
			ansor2,
			ansor3,
			goodsData1,
			goodsData2,
			partsData1,
			accountLevel,
			accountcontent,
			userinfor
		}
	}
}
module.exports = HomeController;
